<script>
import HeaderNav from '@/components/HeaderNav.vue'
import TaskContainer from '@/components/TaskContainer.vue'
import TaskItem from '@/components/TaskItem.vue'
import Condition from '@/components/Condition.vue' 
import TaskCodeView from './task/TaskCodeView.vue'
import TaskPreviewView from './task/TaskPreviewView.vue'
import Footor from '@/components/Footor.vue'

export default {
	components: {
		HeaderNav,
		TaskItem,
		TaskContainer,
		Condition,
		TaskCodeView,
		TaskPreviewView,
		Footor,
	},
	data() {
		return {
			showDialog: false,
			showPreviewDialog: false,
			pagination: {
				page: 1,
				rows: 20,
			},
			condition: {}, // 查询条件
			conditionList: [
				{
					name: "编程语言",
					value: 'langName',  // 查询条件对应的键
					list: [
						{ id: 1, name: "Java" },
						{ id: 2, name: "Python" },
					],
				},
				{
					name: "难易程度",
					value: 'leave',  // 查询条件对应的键
					list: [
						{ id: "简单题", name: "简单题" },
						{ id: "中等题", name: "中等题" },
						{ id: "难题", name: "难题" },
						{ id: "选做题", name: "选做题" },
					],
					multi: true, // 支持多选
				},
				{
					name: "任务状态",
					value: 'status',  // 查询条件对应的键
					list: [
						{ id: 0, name: "未开始" },
						{ id: 1, name: "进行中" },
						{ id: 2, name: "需讲解" },
						{ id: 3, name: "已提交" },
						{ id: 4, name: "已检查" },
						{ id: -1, name: "异常题" },
						{ id: 5, name: "已完成" },
					],
					multi: true, // 支持多选
				}
			]
		}
	},
	methods: {
		handlerCode() {
			this.showDialog = true ;
		},
		previewTask() {
			this.showPreviewDialog = true ;
		}
	}
}
</script>

<template>
	<main class="normal-view">
		<!-- 系统导航 -->
		<HeaderNav active-index="0" class="nav-glass"></HeaderNav>
		<div class="glass-background"></div>

		<div class="content-wrapper">
			<!-- 搜索条件 -->
			<Condition :conditionList="conditionList" v-model="condition" class="condition-glass" />

			<!-- 任务列表 -->
			<div class="task-container-glass">
				<div class="task-items">
					<TaskItem v-for="n in 20" :key="n" :id="1" :leave="1" lang-name="java" title="测试任务" :status="2"
						module-name="java基础" 
						@update:code="handlerCode"
						@preview:task="previewTask"
						@start-task=""
						@over-task=""/>
				</div>

				<!-- 添加分页插件 -->
				<div class="pagination-wrapper">
					<el-pagination background layout="prev, pager, next" hide-on-single-page
						:page-size="pagination.rows" :pager-count="11" v-model:current-page="pagination.page"
						:total="1000" />
				</div>
			</div>
		</div>
	</main>

	<Footor></Footor>

	<el-dialog v-model="showDialog" title="任务提交" width="70%" top="5vh">
		<TaskCodeView />
		<template #footer>
		<div class="dialog-footer">
			<el-button type="primary" @click="showDialog = false">保存</el-button>
			<el-button @click="showDialog = false">关闭</el-button>
		</div>
		</template>
	</el-dialog>

	<el-dialog v-model="showPreviewDialog" title="任务预览" width="70%">
		<TaskPreviewView />
	</el-dialog>
</template>

<style scoped>
.normal-view {
	min-height: 100vh;
	position: relative;
	background: linear-gradient(135deg, #151824 0%, #1c1f35 100%);
}

.content-wrapper {
	margin: 0 auto;
	padding: 20px 50px;
	position: relative;
	z-index: 1;
}

.glass-background {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-image:
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03) 0%, transparent 1px),
		radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.03) 0%, transparent 1px);
	background-size: 24px 24px;
	background-position: 0 0, 12px 12px;
	opacity: 0.5;
	z-index: 0;
}

.nav-glass,
.condition-glass,
.task-container-glass {
	backdrop-filter: blur(12px);
	background: rgba(21, 24, 42, 0.4);
	border: 1px solid rgba(255, 255, 255, 0.05);
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	margin-bottom: 20px;
	position: relative;
	z-index: 1;
}

.task-container-glass {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	padding: 24px;
}

.task-items {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	width: 100%;
}

.task-items>* {
	flex: 1 1 calc(25% - 20px);
	/* 每行展示4个任务 */
	box-sizing: border-box;
	transition: transform 0.3s, box-shadow 0.3s;
}

.task-items>*:hover {
	transform: translateY(-5px);
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.pagination-wrapper {
	margin-top: 20px;
	display: flex;
	justify-content: center;
}

/* 添加分页样式 */
:deep(.el-pagination) {
	color: white;
	/* 设置页码字体颜色为白色 */
}

:deep(.el-pagination.is-background button),
:deep(.el-pagination.is-background .el-pager li) {
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: #e6e8f0;
	/* 设置按钮和页码的字体颜色 */
}

:deep(.el-pagination.is-background .el-pager li.is-active) {
	background: rgba(74, 128, 255, 0.2);
	border-color: rgba(74, 128, 255, 0.3);
	color: #7a9dff;
	/* 设置当前页码的字体颜色 */
}

:deep(.el-pagination.is-background button:hover),
:deep(.el-pagination.is-background .el-pager li:hover) {
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff !important;
	/* 设置悬停时的字体颜色 */
}
</style>
